using UnityEngine;
using UnityEngine.UI;
using QFramework;
using UnityEngine.SceneManagement;

namespace Survivor
{
    public class UIGamePassPanelData : UIPanelData
    {
    }

    public partial class UIGamePassPanel : UIPanel
    {
        protected override void OnInit(IUIData uiData = null)
        {
            mData = uiData as UIGamePassPanelData ?? new UIGamePassPanelData();

            AudioKit.PlaySound("GamePass");
            ActionKit.OnUpdate.Register(() =>
            {
                if (!Input.GetKeyDown(KeyCode.Space))
                    return;
                Global.ResetData();
                SceneManager.LoadScene("Game");
                CloseSelf();
            }).UnRegisterWhenGameObjectDestroyed(this);
            
            BackToStartGameBtn.onClick.AddListener(() =>
            {
                SceneManager.LoadScene("GameStart");
                CloseSelf();
            });
        }

        protected override void OnOpen(IUIData uiData = null)
        {
        }

        protected override void OnShow()
        {
        }

        protected override void OnHide()
        {
        }

        protected override void OnClose()
        {
        }
    }
}